<#include "../common/header.htm">
<body class="gray-bg top-navigation" style="background-color: #fff;">
<div class="content-wrapper">
	<section class="content">
		<div class="row">
			<div class="col-sm-12">
				<div class="tabs-container">
					<ul class="nav nav-tabs navzi">
                        <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">一键导入</a>
                        </li>
                        <li class="">
                        	<a data-toggle="tab" href="#tab-2" aria-expanded="false">自定义导入</a>
                        </li>
                    </ul>
					<div class="tab-content">
						<div id="tab-1" class="tab-pane active">
							<button type="button" class="btn btn-default imbtn" title="导入说明"
								data-container="body" data-toggle="popover" data-placement="left"
								data-content="<li>1,一键导入主要针对在模板库存中存在的账单</li><li>2,自定义导入主要针对格式化比较复杂的账单，导入完成后需手动配置账单标题</li>">
							导入说明
						</button>
						<div class="importti">
							<span class="sming"></span>
							<span class="importfont">"温馨提示：每次选择导入的文件不要超过10个，主要支持的文件格式有：.xls，.xlsx，.csv，.pdf，.txt"</span>
						</div>
							<div class="panel-body">
								<div class="box">
									<form action="#" method="get" id="listForm" >
										<div class="form-group">
											<input id="file-1" accept=".pdf,.csv, .xlsx, .xls,.txt" type="file" name="fileUpload" multiple="multiple" class="file" data-overwrite-initial="false" />
											<input type="hidden" id="nextNumber" name="nextNumber" value="${nextNumber!}"/>
											<input type="hidden" id="callbackResult" name="callbackResult"/>
										</div>
									</form>
								</div>
								<!--上传按钮 bengin-->
								<div class="importAndClear">
									<button onclick="beginImport()"  type="button" class="btn btn-primary up">
										开始导入
									</button>

									<!--<a href="#" style="display: none;" onclick="clearFile()">清空</a>-->
								</div>
							</div>
							<!--<button onclick="showCaseObjectMapping()" type="button" id="caseObjectBill" style="display: none;" class="gldx el-button el-button&#45;&#45;primary">
								关联案件对象<span class="gldxwen" data-container="body" data-toggle="popover" data-placement="top"
											data-content="<li>1,一键导入主要针对在模板库存中存在的账单</li><li>2,自定义导入主要针对格式化比较复杂的账单，导入完成后需手动配置账单标题</li>"></span>
							</button>-->
							<button onclick="showCaseObjectMapping()" type="button" id="caseObjectBill" style="display: none;" class="gldx el-button el-button--primary gldxwen"  data-container="body" data-toggle="popover" data-placement="top"
									data-content="如果导入的数据不包含姓名，企业名称,身份证号等信息，可通过“关联案件对象”完善信息，便于更精准的展示分析结果">
								关联案件对象
							</button>
							<!-- end -->
							<!--导入结果-->
							<div class="result">
								<el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
									<el-tab-pane label="导入结果" name="first">
										<div class="importrt" id="importrtTitle"></div>
										<table id="dg"></table>
									</el-tab-pane>
									<el-tab-pane label="已导入数据" name="second">
										<el-select v-model="excelVal" placeholder="请选择" @change="changeHandle">
											<el-option
													v-for="item in logDataArr"
													:key="item.DEAL_FLOW_UUID"
													:label="item.FILE_NAME"
													:value="item.DEAL_FLOW_UUID">
											</el-option>
										</el-select>
										<div class="detail">
											<table id="dg2"></table>
										</div>
									</el-tab-pane>
								</el-tabs>
							</div>
						</div>
						<div id="tab-2" class="tab-pane">
                            <div class="panel-body">
                                <form action="#" method="get" >
									<div class="form-group">
										<input id="file-2" accept=".pdf,.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,.txt" type="file" name="fileUpload" multiple="multiple" class="file" data-overwrite-initial="false" />
									</div>
								</form>
								<div class="importAndClearZdy">
									<button onclick="beginMapping()" id="beginMapping" style="margin-left: 106px;" type="button" class="btn btn-primary be">
										开始解析
									</button>
									<button onclick="zdyClearFile()" id="clearFile" style="display: none;" type="button" class="btn btn-primary zdyclear">
										清空
									</button>
									<button onclick="importZdy()" id="importZdy" type="button" style="display: none;" class="btn btn-primary ex">
										导入
									</button>

								</div>
							</div>
							<div class="zdyresult">
								<div class="importtscon">
									<span class="importbgk">账单概况</span>
									<span class="importbz">注：如果标题对应不上，请匹配标题，或通过标题管理添加标题，方便下次导入</span>
									<button onclick="initTitlePoll()" type="button" class="btn btn-primary ex">
										标题管理
									</button>
									<button onclick="" type="button" class="btn btn-primary importbh">
										选中行设为标题行
									</button>

								</div>
								<table id="zdydg"></table>
							</div>
							<div class="zdyresultend">
								<!--导入结果-->

								<el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
									<el-tab-pane label="导入结果" name="first">
										<table id="dgzdy"></table>
									</el-tab-pane>
									<el-tab-pane label="已导入数据" name="second">
										<el-select v-model="excelVal" placeholder="请选择" @change="changeHandle">
											<el-option
													v-for="item in logDataArr"
													:key="item.DEAL_FLOW_UUID"
													:label="item.FILE_NAME"
													:value="item.DEAL_FLOW_UUID">
											</el-option>
										</el-select>
										<div class="detail">
											<table id="dg2zdy"></table>
										</div>
									</el-tab-pane>
								</el-tabs>
	                        </div>
                        </div>
					</div>
				</div>
			</div>
		</div>
	</section>
</div>
</body>
<script type="text/javascript">
   	var caseId=parent.caseId;
   	/*导入成功文件id*/
   	var fileUUids = new Array();
    $(function(){
    	$.ajax({
	        type : "GET",
	        url : "${ctx}/casemanage/setCaseUuid?caseUuid="+caseId,
	        success: function(data){
	        }
	    });
        $("[data-toggle='popover']").popover({html : true,trigger:'hover', });
        $(".billreferbtn").click(function(){
            $(this).find(".glyphicon").toggleClass("glyphicon-menu-down");
            $(this).find(".glyphicon").toggleClass("glyphicon-menu-up")
        })
        $(".billreferbtn").mouseout(function(){
            // $(this).find(".glyphicon").removeClass("glyphicon-menu-up");
        })
    })
    /*初始化fileinput插件*/
    var obj=$("#file-1").fileinput({
        language: 'zh',//汉化
        uploadUrl : '${ctx}/bill/xx?uid='+caseId,//上传地址
        allowedFileExtensions : ['txt' ,'csv', 'xls' , 'xlsx','pdf'],//支持格式
        showClose : false,//屏蔽x号关闭案件
        uploadAsync:false,//采用同步上传
        showUploadedThumbs : false,//是否在预览窗口中持续显示上传的文件缩略图
        overwriteInitial : false,//将其设置为false将有助于始终从数据库中显示已保存的图像或文件
        browseOnZoneClick : true,//浏览区域点击
        autoReplace : true,//是否自动替换当前文件，设置为true时，再次选择文件， 会将当前的文件替换掉。
        maxFileSize : 0,
        maxFilesNum : 0,
        maxFileCount:10,
        showBrowse:true,
        showUpload: true,//Boolean 是否显示上传按钮 true,
        showRemove : true,//关闭删除按钮
        removeFromPreviewOnError : true,
        layoutTemplates :{
            actionUpload : '',
            actionZoom : ''   //去除上传预览缩略图中的查看详情预览的缩略图标。
        },
        previewSettings: {
            image: {width: "100px", height: "100px"},
        },
        initialPreviewAsData: true,
        allowedPreviewTypes :null, //设置为空，null或false以禁用所有类型的预览
        showPreview :true, //是否显示预览
        preferIconicPreview: true, // 开启用图标替换预览效果
       /* previewFileIconSettings: {
            'docx': '<i class="fa fa-file-word-o text-primary"></i>',
            'xlsx': '<i class="fa fa-file-excel-o text-success"></i>',
            'pptx': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
            'doc': '<i class="fa fa-file-word-o text-primary"></i>',
            'xls': '<i class="fa fa-file-excel-o text-success"></i>',
            'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
            'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
            'txt': '<i class="fa fa-file-text-o text-info"></i>',
        },*/
        slugCallback : function(filename) {
            return filename.replace('(', '_').replace(']', '_');
        }
    }).on('filepreupload', function(event, data, previewId, index) {     //上传中
        var form = data.form, files = data.files,filenames = data.filename, extra = data.extra,
            response = data.response, reader = data.reader;
    }).on("filebatchuploadsuccess", function(event, data) {    //文件上传成功
    	fileUUids = new Array();
        $('.result').show();
        $('#caseObjectBill').show();
        $(".importAndClear button").html("开始导入")
        $(".importAndClear button").attr('disabled',false);
        $(".importAndClear a").show();
        var ids=data.response.data.ids;
           $('#importrtTitle').html("本次共选择"+data.response.data.totalFile+"个文件，导入成功"+data.response.data.successFile+"个，失败"+data.response.data.errorFile+"个");
        if (ids){
            dg(ids)
        }
        $(".fileinput-remove-button").click();
        window.parent.refreshTree();
    }).on("filesuccessremove", function(event, data) {
        //检查当前文件的个数，如果等于0的话就清空当前页面
        if ($(".file-preview-frame").length==1) {
            clearFile();
        }
    }).on("filebatchselected",function (event, files) {//文件被上传
        if (files.length>0){
			for (let i = 0; i < files.length; i++) {
				let filename=files[i].name;
				changFilePng(filename,i)
			}
            $(".importAndClear a").show()
        }else{
            $(".importAndClear a").hide()
        }
    });

    /*列显示下拉框*/
    var cmenu;
	/* 未匹配上的标题 */
	var tempTitle;
	/* 匹配上的标题 */
	var mappingTitle;
	/* 选中要匹配的标题行 */
	var selectRowIndex;
	/*文件名称*/
	var fileName;
	/*文件大小*/
	var fileSize;
	/* 文件唯一标识符 */
	var fileUuid;
	function importZdy(){
		var data = {"mappingTitle" : mappingTitle,"selectRowIndex": selectRowIndex,"fileUuid": fileUuid,"fileName": fileName,"fileSize": fileSize,caseId:caseId};
		$.ajax({
        	type : "post",
            url : "${ctx}/bill/zdyImport",
            contentType : "application/json;charset=UTF-8",
            data : JSON.stringify(data),
            success : function (data) {
        		if (data.ids){
	        		$(".zdyresult").hide();
	        		$("#importZdy").attr("style","display:none;");
	        		$("#beginMapping").html("开始解析")
	        		$("#beginMapping").attr("disabled",false);
	        		$("#clearFile").attr("style","display:none;");
	        		$(".fileinput-remove-button").click();
	        		$(".zdyresultend").show();
        			dgzdy(data.ids)
        		}
            }
        });
	};
	/* 初始化fileinput插件 */
	var obj=$("#file-2").fileinput({
		language: 'zh',//汉化
		uploadUrl : '${ctx}/bill/billImportMapping?uid='+caseId,//上传地址
		allowedFileExtensions : ['txt' ,'csv', 'xls' , 'xlsx','pdf'],//支持格式
		showClose : false,//屏蔽x号关闭案件
		uploadAsync:false,//采用同步上传
		showUploadedThumbs : false,//是否在预览窗口中持续显示上传的文件缩略图
		overwriteInitial : false,//将其设置为false将有助于始终从数据库中显示已保存的图像或文件
		browseOnZoneClick : true,//浏览区域点击
		autoReplace : true,//是否自动替换当前文件，设置为true时，再次选择文件， 会将当前的文件替换掉。
		maxFileSize : 0,
		maxFilesNum : 0,
		maxFileCount:1,
		showBrowse:true,
		showUpload: true,//Boolean 是否显示上传按钮 true,
		showRemove : true,//关闭删除按钮
		removeFromPreviewOnError : true,
		layoutTemplates :{
			actionUpload : '',
			actionZoom : ''   //去除上传预览缩略图中的查看详情预览的缩略图标。
		},
		previewSettings: {
			image: {width: "100px", height: "100px"},
		},
		initialPreviewAsData: true,
		allowedPreviewTypes :null, //设置为空，null或false以禁用所有类型的预览
		showPreview :true, //是否显示预览
		preferIconicPreview: true, // 开启用图标替换预览效果
		/*previewFileIconSettings: {
			'docx': '<i class="fa fa-file-word-o text-primary"></i>',
			'xlsx': '<i class="fa fa-file-excel-o text-success"></i>',
			'pptx': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
			'doc': '<i class="fa fa-file-word-o text-primary"></i>',
			'xls': '<i class="fa fa-file-excel-o text-success"></i>',
			'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
			'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
			'txt': '<i class="fa fa-file-text-o text-info"></i>',
		},*/
		slugCallback : function(filename) {
			return filename.replace('(', '_').replace(']', '_');
		}
	}).on('filepreupload', function(event, data, previewId, index) {     //上传中
		var form = data.form, files = data.files,filenames = data.filename, extra = data.extra,
				response = data.response, reader = data.reader;
	}).on('filebatchuploaderror', function(event, data, msg) {
		$('.zdyresult').hide();
		$("#importZdy").attr("style","display:none;");
		$("#clearFile").attr("style","display:none;");
		$("#beginMapping").html("开始解析")
		$("#beginMapping").attr("disabled",false);
		$(".fileinput-remove-button").click();
		toastr.error(data.response.data);
	}).on("filebatchuploadsuccess", function(event, data) {   //文件上传成功
        if(data.response.result =='fail'){
        	$('.zdyresult').hide();
    		$("#importZdy").attr("style","display:none;");
    		$("#clearFile").attr("style","display:none;");
    		$("#beginMapping").html("开始解析")
    		$("#beginMapping").attr("disabled",false);
    		$(".fileinput-remove-button").click();
        	toastr.error(data.response.data);
        }else{
			fileUuid = data.response.data[0].fileUuid;
			fileName = data.files[0].name;
			fileSize = data.files[0].size;
			$('.zdyresult').show();
			$("#beginMapping").attr("disabled",true);
			var collll = new Array();
	    	$.ajax({
		        url:"${ctx}/bill/findTempColumnSize",
		        type : "get",
		        dataType :'json',
		        data:{caseId: caseId},
		        success : function (obj) {
		        	for (i = 0; i < Number(obj) -1; i++) { 
		        		var index = i + 1;
	                    var str = {"field": "TEMP_"+index,"align": "center","title": "未知"+index};
	                    collll.push(str);
	        	    }
		        	collll = [collll];
                    debugger
		        	$('#zdydg').datagrid({
		    			url:"${ctx}/bill/findDealFlowTemp4Page?caseId="+caseId,
		    			columns: collll,
		    			height:($(window).height())-($('.panel-body').height())-400,
		    			method: 'post',
		    			iconCls: 'icon-save',
		    			width:1500,
		    			pageList:[20,40,50,100],//每页记录数选择范围设置
		    			pageNumber:1,//当前页号,
		    			pageSize:20,//每页显示记录数
		    			loadMsg:"正在加载，请稍后",//加载数据时的提示信息
		    			emptyMsg:"暂无信息",//加载数据为空时的信息
		    			//height: 710,
		    			rownumbers:true,//序号
		    			fitColumns: true,//使表格自适应页面宽度
		    			pagination: true,//是否分页
		    			singleSelect: true,
		                onClickRow: function(rowIndex, rowData){
		                	//选中标题行
		                	$.ajax({
		            			url: "${ctx}/bill/TempTitleMapping",
		            			data: rowData,
		            			success: function (data) {
		            				var str = '';
		            				$.each(data.mappingTitle ,function (i,n) {
		            					var newStr=i.substring(i.lastIndexOf('_'),i.length); 
		            					var option = $('#zdydg').datagrid("getColumnOption", "TEMP"+newStr)
		            					option.title = n;
			                		});
		            				$('#zdydg').datagrid();
		            				mappingTitle = data.mappingTitle;
		            				tempTitle = data.notInTitle;
		            				selectRowIndex = rowIndex;
		                        }
		            		});
		                },
		                onLoadSuccess:function(){//修改未匹配上的标题颜色
		                	// 更改表头颜色
		                	var trArr = $(this).prev().find("tr.datagrid-header-row");
		                	var trObj = trArr[0];
		                	var tdArr = trObj.cells;
		                	for (var i = 0; i < tdArr.length; i++) {
		                		if(tdArr[i].innerText.indexOf("未知") >= 0) { 
		                			tdArr[i].style.backgroundColor = "red";
		                			$("#importZdy").attr("style","display:none;");
		                		}
		                	}
		                	if(trObj.innerText.indexOf("未知") < 0){
		                		$("#importZdy").attr("style","display:initial;");
		                	}
	                	},
		                onHeaderContextMenu: function(e, field){//设置标题右键菜单
		                    e.preventDefault();
		                    cmenu = $('<div/>').appendTo('body');
		                    cmenu.menu({
		                    	onClick: function(item){
		                    		//获取点击的字段对象
		                    		var option = $('#zdydg').datagrid("getColumnOption", field)
		                    		//设置标题名称
	            					option.title = item.name;
		                    		$('#zdydg').datagrid();
		                    		//删除选择后的标题
		                    		removeByValue(tempTitle,item.name);
		                    		//更新匹配上的标题
		                    		mappingTitle[field] = item.name;
		                        }
		                    });
		                    if(tempTitle != null){
		                    	for(var i = 0; i < tempTitle.length; i++){
		                            var f = tempTitle[i];
		                            cmenu.menu('appendItem', {
		                                text: f,
		                                name: f
		                            });
		                        }
		                    }
		                    cmenu.menu('show', {
		                        left:e.pageX,
		                        top:e.pageY
		                    });
		                }
		    		});
		        }
		    });
        }
	}).on("filebatchselected",function (event, files) {//文件被上传
		if (files&&files.length>0){
			$("#clearFile").show();
		}else{
			$("#clearFile").hide();
		}
	});
    $(function () {
        $(".input-group.file-caption-main.no-browse").hide();
        $(".input-group.file-caption-main").hide();
    });
    function beginImport() {
        let fileLength=$(".file-preview-frame").length;
        if (!fileLength) {
            toastr.info("请选择文件");
            return;
        }
        $('.result').hide();
        $('#caseObjectBill').hide();
        $(".fileinput-upload-button").click();
        $(".importAndClear button").html("正在导入...")
        $(".importAndClear button").attr('disabled',true);
        $(".importAndClear a").hide();
        importLog.excelVal=''
        importLog.logDataArr=[]
        importLog.activeName='first'
    };
    function beginMapping() {
		let fileLength=$(".file-preview-frame").length;
		if (!fileLength) {
			toastr.info("请选择文件");
			return;
		}
		$(".fileinput-upload-button").click();
		$("#beginMapping").html("解析中...");
    	$("#beginMapping").attr("disabled",true);
		$('.zdyresult').hide();
		importLog2.excelVal=''
		importLog2.logDataArr=[]
		importLog2.activeName='first'
	};
    function clearFile() {
        $('.result').hide();
        $(".fileinput-remove-button").click();
        $('#caseObjectBill').hide();
    };
    function zdyClearFile() {
		$('.zdyresult').hide();
		$("#importZdy").attr("style","display:none;");
		$("#clearFile").attr("style","display:none;");
		$("#beginMapping").html("开始解析")
		$("#beginMapping").attr("disabled",false);
		$(".fileinput-remove-button").click();
	};
    function dg(ids){
        $('#dg').datagrid({
            url: '${ctx}/datalog/importDataList_easyui',
            method: 'post',
            iconCls: 'icon-save',
            queryParams:{//每次请求的参数
                ids: ids,
                caseId:caseId
            },
            pageList:[10,20,40,50,100],//每页记录数选择范围设置
            pageNumber:1,//当前页号,
            pageSize:20,//每页显示记录数
            loadMsg:"正在加载，请稍后",//加载数据时的提示信息
            emptyMsg:"暂无信息",//加载数据为空时的信息
            //height: 710,
            // width:1300,
            rownumbers:true,//序号
            fitColumns: true,//使表格自适应页面宽度
            pagination: true,//是否分页
            singleSelect: true,
            columns:[[ //每一列的具体设置。
                {field:'FILE_NAME',title:'文件名',width:'20%'},
                {field:'FILE_SIZE',title:'文件大小',width:'20%',
					formatter: function(value,row,index){ //当前值，当前的row，当前的索引
						if (value < 1024) {
				            return value + 'B';
				      	} else if (value < (1024*1024)) {
				            var temp = value / 1024;
				            temp = temp.toFixed(2);
				            return temp + 'KB';
				      	} else if (value < (1024*1024*1024)) {
				        	var temp = value / (1024*1024);
				            temp = temp.toFixed(2);
				         	return temp + 'MB';
				    	} else {
				         	var temp = value / (1024*1024*1024);
				         	temp = temp.toFixed(2);
				         	return temp + 'GB';
				      	}
						return value;
					}
				},
                {field:'IMPORT_RESULT',title:'导入结果',width:'20%',
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                        value+="(导入"+row.SUCCESS_NUMBER+"条)"
                        return value
                    }
                },
                {field:'IMPORT_DESC',title:'失败原因',width:'20%'},
                {field:'CCCCC',title:'操作',align:'center',
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                    	if(row.IMPORT_RESULT == '成功'){
                        	return "<a href='#' onclick='delLog(\""+row.DEAL_FLOW_UUID+"\",1,\""+row.IMPORTDETAILID+"\")'>删 除</a>"
                    	}else{
                    		return "-";
                    	}
                    }
                }
            ]],
            onLoadSuccess: function(data){
            	console.log(data);
                if (!data.rows.length){
                    $('.result').hide()
                }else{
                    importLog.logDataArr=data.rows;
                    //文件导入成功，将文件DEAL_FLOW_UUID保存fileUUids
                    $.each(data.rows ,function (i,n) {
                    	fileUUids.push(n.DEAL_FLOW_UUID);
            		});
                }
            }
        });
    };
    function dgzdy(ids){
		$('#dgzdy').datagrid({
			url: '${ctx}/datalog/importDataList_easyui',
			method: 'post',
			iconCls: 'icon-save',
			queryParams:{//每次请求的参数
				ids: ids,
				caseId:caseId
			},
			pageList:[10,20,40,50,100],//每页记录数选择范围设置
			pageNumber:1,//当前页号,
			pageSize:10,//每页显示记录数
			loadMsg:"正在加载，请稍后",//加载数据时的提示信息
			emptyMsg:"暂无信息",//加载数据为空时的信息
			//height: 710,
			width:1300,
			rownumbers:true,//序号
			fitColumns: true,//使表格自适应页面宽度
			pagination: true,//是否分页
			singleSelect: true,
			columns:[[ //每一列的具体设置。
				{field:'FILE_NAME',title:'文件名',width:'20%'},
				{field:'FILE_SIZE',title:'文件大小',width:'20%',
					formatter: function(value,row,index){ //当前值，当前的row，当前的索引
						if (value < 1024) {
				            return value + 'B';
				      	} else if (value < (1024*1024)) {
				            var temp = value / 1024;
				            temp = temp.toFixed(2);
				            return temp + 'KB';
				      	} else if (value < (1024*1024*1024)) {
				        	var temp = value / (1024*1024);
				            temp = temp.toFixed(2);
				         	return temp + 'MB';
				    	} else {
				         	var temp = value / (1024*1024*1024);
				         	temp = temp.toFixed(2);
				         	return temp + 'GB';
				      	}
						return value;
					}
				},
				{field:'IMPORT_RESULT',title:'导入结果',width:'20%',
					formatter: function(value,row,index){ //当前值，当前的row，当前的索引
						value+="(导入"+row.SUCCESS_NUMBER+"条)"
						return value
					}
				},
				{field:'IMPORT_DESC',title:'失败原因',width:'20%'},
				{field:'IMPORTDETAILID',title:'操作',align:'center',
					formatter: function(value,row,index){ //当前值，当前的row，当前的索引
						if(row.IMPORT_RESULT == '成功'){
                        	return "<a href='#' onclick='delLog(\""+row.DEAL_FLOW_UUID+"\",1,\""+row.IMPORTDETAILID+"\")'>删 除</a>"
                    	}else{
                    		return "-";
                    	}
					}
				}
			]],
			onLoadSuccess: function(data){

				if (!data.rows.length){
					$('.zdyresultend').hide()
				}else{
					importLog2.logDataArr=data.rows
				}
			}
		});
	};
	function dg2zdy(excelLog){
		if (!caseId) {
			toastr.error("案件id为空");
			return;
		}
		if (!excelLog) {
			excelLog="xxx";//给一个假值，让表头初始化
		}
		$('#dg2zdy').datagrid({
			url: '${ctx}/bill/stream/inaccountstatistics_detail',
			method: 'post',
			iconCls: 'icon-save',
			queryParams:{//每次请求的参数
				uuid: excelLog,
				casemanageId:caseId
			},
			height:0,
			width:1500,
			pageList:[20,40,50,100],//每页记录数选择范围设置
			pageNumber:1,//当前页号,
			pageSize:20,//每页显示记录数
			loadMsg:"正在加载，请稍后",//加载数据时的提示信息
			emptyMsg:"暂无信息",//加载数据为空时的信息
			rownumbers:true,//序号
			fitColumns: true,//使表格自适应页面宽度
			pagination: true,//是否分页
			singleSelect: true,
			columns:[[ //每一列的具体设置。
				{field:'ACCOUNT_BODY',title:'交易主体'},
				{field:'ACCOUNT_BODY_NUMBER',title:'交易主体账号'},
				{field:'ACCOUNT_BODY_CARD',title:'交易主体卡号'},
				{field:'ACCOUNT_RIVAL',title:'交易对手'},
				{field:'ACCOUNT_RIVAL_NUMBER',title:'交易对手账号'},
				{field:'ACCOUNT_RIVAL_CARD',title:'交易对手卡号'},
				{field:'SIGN',title:'交易类型',
					formatter: function(value,row,index){ //当前值，当前的row，当前的索引
						return value==0?'流入':'流出'
					}
				},
				{field:'TRADE_DATE',title:'交易时间',
					formatter: function(value,row,index){ //当前值，当前的row，当前的索引
						if(value){
							var date = new Date(value);
							return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
						}else{
							return '-';
						}
					}
				},
				{field:'ACCOUNT_MONEY',title:'交易金额', sortable : true},
				{field:'SURPLUS_MONEY',title:'交易后余额', sortable : true},
				{field:'CONTENT_ABSTRACT',title:'摘要'},
				{field:'ACCOUNT_RIVAL_BANK',title:'对手归属行'},
				{field:'ACCOUNT_BODY_BANK',title:'主体归属行'},
				{field:'INSTITUTION_NUMBER',title:'对方机构号'},
				{field:'TELLER_NUMBER',title:'柜员号'},
				{field:'REMARKS',title:'备注'}
			]],
			onLoadSuccess: function(data){
			}
		});
	};
    function dg2(excelLog){
        var casemanageId = parent.caseId;
        if (!casemanageId) {
            toastr.error("案件id为空");
            return;
        }
        if (!excelLog) {
            excelLog="xxx";//给一个假值，让表头初始化
        }
        $('#dg2').datagrid({
            url: '${ctx}/bill/stream/inaccountstatistics_detail',
            method: 'post',
            iconCls: 'icon-save',
            queryParams:{//每次请求的参数
                uuid: excelLog,
                casemanageId:casemanageId
            },
            pageList:[10,20,40,50,100],//每页记录数选择范围设置
            pageNumber:1,//当前页号,
            pageSize:20,//每页显示记录数
            loadMsg:"正在加载，请稍后",//加载数据时的提示信息
            emptyMsg:"暂无信息",//加载数据为空时的信息
            //height: 710,
            rownumbers:true,//序号
            fitColumns: true,//使表格自适应页面宽度
            pagination: true,//是否分页
            singleSelect: true,
            columns:[[ //每一列的具体设置。
                {field:'ACCOUNT_BODY',title:'交易主体'},
                {field:'ACCOUNT_BODY_NUMBER',title:'交易主体账号'},
                {field:'ACCOUNT_BODY_CARD',title:'交易主体卡号'},
                {field:'ACCOUNT_RIVAL',title:'交易对手'},
                {field:'ACCOUNT_RIVAL_NUMBER',title:'交易对手账号'},
                {field:'ACCOUNT_RIVAL_CARD',title:'交易对手卡号'},
                {field:'SIGN',title:'交易类型',
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                        return value==0?'流入':'流出'
                    }
                },
                {field:'TRADE_DATE',title:'交易时间',
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                        if(value){
                            var date = new Date(value);
                            return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
                        }else{
                            return '-';
                        }
                    }
                },
                {field:'ACCOUNT_MONEY',title:'交易金额', sortable : true},
                {field:'SURPLUS_MONEY',title:'交易后余额', sortable : true},
                {field:'CONTENT_ABSTRACT',title:'摘要'},
                {field:'ACCOUNT_RIVAL_BANK',title:'对手归属行'},
                {field:'ACCOUNT_BODY_BANK',title:'主体归属行'},
                {field:'INSTITUTION_NUMBER',title:'对方机构号'},
                {field:'TELLER_NUMBER',title:'柜员号'},
                {field:'REMARKS',title:'备注'}
            ]],
            onLoadSuccess: function(data){
            }
        });
    }
    function delLog(dealFlowUuid,tableFlat,importDetailId){
        $.ajax({
            url: "${ctx}/datalog/deleteFlow",
            type: "post",
            data: {
                dealFlowUuid: dealFlowUuid,
                tableFlat:tableFlat,
                caseManagerId:parent.caseId,
                importDetailId:importDetailId
            },
            success: function (msg) {
                toastr.success("删除成功");
                $('#dg').datagrid('reload');
            }
        })
    };
    function initTitlePoll(){
        var d = top.dialog({
            title : "标题管理",
            modal : true,
            url : '${ctx}/bill/titlepool/showTitlePool',
            height : 800,
            width : 1500,
            onclose : function() {
                window.location.reload();
            }

        });
        d.show();
        return false;
	};
	function showCaseObjectMapping(){
		var data = {"fileUUids": fileUUids,"casemanageId": caseId}
        var d = top.dialog({
            title : "关联案件对象",
            modal : true,
            url : '${ctx}/casemanage/showCaseObjectBillMapping',
            height : 880,
            width : 1500,
            data : data
        });
        d.show();
        return false;
	};
	function removeByValue(arr, val) {
		for(var i = 0; i < arr.length; i++) {
			if(arr[i] == val) {
				arr.splice(i, 1);
				break;
			}
		}
	};
    var importLog=new Vue({
        el: ".result",
        visible: false,
        data: {
            logDataArr: [],
            excelVal: '',
            activeName:'first',
        },
        methods: {
            handleClick(){
                if (this.activeName=='second'&&this.logDataArr.length>0) {
                    this.excelVal=this.logDataArr[0].DEAL_FLOW_UUID
                }else{
                    this.excelVal=''   //初始化uuid
                }
                this.changeHandle()
            },
            changeHandle(){
                dg2(this.excelVal);
            }
        }
    });
    var importLog2=new Vue({
		el: ".zdyresultend",
		data: {
			logDataArr: [],
			excelVal: '',
			activeName:'first',
		},
		methods: {
			handleClick(){
				if (this.activeName=='second'&&this.logDataArr.length>0) {
					this.excelVal=this.logDataArr[0].DEAL_FLOW_UUID
				}else{
					this.excelVal=''   //初始化uuid
				}
				this.changeHandle()
			},
			changeHandle(){
				dg2zdy(this.excelVal);
			}
		}
	});
</script>
<style>
	.form-group{
		margin-top: 10px;
	}
	button.btn.btn-primary.importbh {
		float: right;
		background-color: #52c41a;
		border-radius: 4px;
		border-color: #52c41a;
		margin-top: -8px;
	}
	button.btn.btn-primary.ex {
		float: right;
		margin-left: 12px;
		background-color: #23b7e5;
		border-radius: 4px;
		border-color: #23b7e5;
		margin-top: -8px;
	}
	.zdyresult {
		padding: 0px 10px 0 20px;
		margin-top: 5px;
	}
	span.importbgk {
		font-size: 14px;
		margin-right: 12px;
		color: #333333;
	}
	span.importbz {
		font-size: 12px;
	}
	::-webkit-scrollbar
	{
		height: 6px;
	}
	.zdyinp{
		margin-top: 10px;
	}
	.file-preview {
		height: 100%;
	}
	.file-drop-zone.clickable {
		min-height: 220px;
	}
	span.gldxwen {
		background:url("${ctx}/imgs/gldxwen.png") no-repeat;
		display: inline-block;
		width: 14px;
		height: 14px;
		vertical-align: middle;
		margin-left: 5px;
	}
	.gldx {
		width: 130px!important;
		height: 30px;
		line-height: 6px;
		margin-right: -3px;
		position: absolute;
		top: 413px;
		right: 40px;
		z-index: 2;
	}
	.file-preview{
		border-color: transparent;
		padding: 0;
		height: 100%;
	}
	.file-drop-zone.clickable {
		min-height: 220px;
	}
	.importrt {
		margin-top: 10px;
		margin-bottom: -10px;
	}
	.el-popover, .el-tabs--border-card{
		box-shadow: none;
	}
	.datagrid-view2 {
		padding-left: 30px;
	}
	.panel.datagrid.panel-htop{
		width: 100%!important;
	}
	.datagrid-view2{
		width: 100%!important;
	}

	span.sming {
		position: absolute;
		top: 8px;
		left: 8px;
	}
	span.importfont {
		margin-left: 30px;
	}
	button.btn.btn-default.imbtn {
		position: absolute;
		right: 25px;
		z-index: 1;
		background-color: transparent;
		border-color: transparent;
		color: #287CDF;
		top: 9px;
	}
	.btn-default{
		background-color:transparent;
		border-color: transparent;
	}
	.btn-default:hover{
		background-color: transparent;
		border-color: transparent;
		color: #3296f1!important;
	}
	.btn-default:active{
		background-color: transparent;
		border-color: transparent;
		color: #0c76d7;
		outline-color: transparent;
	}
	.btn-default:focus{
		background-color: transparent;
		border-color: transparent!important;
		color: #0c76d7!important;
	}
	.btn:focus{
		outline: none;
	}
	.el-popover__title {
		font-size: 14px;
		font-weight: 600;
	}
	.el-popover{
		line-height: 20px;
	}
	.importck {
		color: #287CDF;
		cursor: pointer;
	}
	.importck:hover {
		color: #3296f1;
	}
	button.el-button.el-button--default {
		border: transparent;
		position: absolute;
		right: 55px;
		top: 0px;
		color: #287CDF;
		z-index: 20;
		background: transparent;
	}
	button.el-button.el-button--default:hover{
		background-color: transparent;
	}
	span.glyphicon.glyphicon-menu-down {
		padding-left: 7px;
	}
	span.glyphicon.glyphicon-menu-up {
		padding-left: 7px;
		font-size: 10px;
	}
	.importti{
		margin-left: 25px;
		height: 30px;
		line-height: 30px;
		margin-top: 10px;
		margin-right: 10px;
	}
	.panel-body {
		border-color: transparent!important;
	}
	ul.nav.nav-tabs.navzi {
		height: 36px;
	}
	ul.nav.nav-tabs.navzi li{
		height: 36px;
	}
	ul.nav.nav-tabs.navzi li a{
		height: 34px;
		line-height: 6px;
	}
	.tabs-container .nav-tabs.navzi > li.active > a{
		border-color: transparent!important;
		color: #000;
	}
	.top-navigation .nav > li a:focus, .top-navigation .nav > li a:hover{
		color: #000;
	}
	.panel-body {
		/*margin-top: 63px;*/
	}

	.file-drop-zone{
		margin: 0;
	}
	#myModalLabel {
		color:black;
		text-align: left;
	}
	div#addform {
		overflow: hidden;
	}
	.modal-body {
		padding: 10px;
	}
	.el-select-dropdown__item.selected{
		background: #FFFFFF;
	}
	.el-select-dropdown__item.selected.hover{
		background: #f5f7f5 !important;
	}
	.el-select-dropdown__item.selected{
		color: #409EFF;
	}
	.importAndClear{
		width: 200px;
		margin: 0 auto;
		height: 40px
	}
	.importAndClearZdy{
		width: 400px;
		margin: 0 auto;
		height: 40px
	}
	.zdyresultend{
		display: none;
	}
	.zdyresult{
		margin-top: 10px;
		display: none;
	}
	.importAndClear a{
		line-height: 40px;
		padding-left: 10px;
	}
	.result{
		display: none;
		padding-left: 20px;
		padding-right: 10px;
		margin-top: 35px;
	}
	.detail{
		margin-top: 20px;
	}
	.el-tabs--border-card>.el-tabs__header .el-tabs__item{
		margin: 0;
	}
	.el-tabs--border-card{
		border-top: transparent;
	}
	.el-tabs__item.is-active {
		border-top: 1px solid #E4E7ED !important;
	}
	.el-tabs__item.is-active {
		color: #000!important;
	}
	.el-tabs__item.is-active {
		height: 40px;
	}
	.el-tabs__nav {
		height: 40px;
	}
	.el-tabs__nav-scroll {
		height: 40px;
	}
	.el-tabs__nav-wrap {
		height: 40px;
	}
	.el-tabs__header {
		height: 40px;
	}
	.el-tabs--border-card > .el-tabs__header{
		background-color: #fff;
	}
	.el-tabs--border-card > .el-tabs__content{
		padding: 0;
	}
	.tabs-container .panel-body{
		padding: 0;
		padding-left: 0;
		padding-right: 0;
	}
	.panel.datagrid.panel-htop {
		border: 1px solid #D3D3D3;
		margin-top: 10px;
	}
	.el-tabs--border-card>.el-tabs__header .el-tabs__item:not(.is-disabled):hover {
		color: #000;
	}
	.el-tabs--border-card{
		border: transparent!important;
	}
	input.el-input__inner {
		margin-top: 20px;
		width: 260px;
		height: 30px;
		border: solid 1px #d9d9d9;
	}
	.el-input__icon{
		top: 35px!important;
	}
	.el-select-dropdown__wrap{
		margin-botoom:-16px!important;
	}
</style>
</html>